/*
 * @Author : Genustin
 * @Date   : 2012-05-31
 * 求数字和
 */
#include <iostream>
#include <cstring>
using namespace std;

int main() 
{
	int num, i, count;
 	int list[15], half, db;
 	memset(list, 0, 15);
 	count = 0;
 	i = 0;

 	cin >> num;
 	while(num != -1) 
 	{
 		if (num != 0) {
 			list[i++] = num;
 		} else {
 			for (int j = 0; j < i; ++j) {
 				for (int k = j+1; k < i; ++k) {
 					half = (list[j]%2 == 0) ? list[j]/2 : 0;
 					db   = list[j] * 2;
 					if (half == list[k] or db == list[k])
 						++count;
 				}
 			}
 			
 			cout << count << endl;
 			memset(list, 0, 15);
 			count = 0;
 			i = 0;
 		}
 		cin >> num;
	}
 	return 0;
}